from app.models.data_base_models import tmall_flagship_store_overview_day_input
from app.services import get_base_session as get_session

def nostattime_insert(classObject: tmall_flagship_store_overview_day_input):
    info = "success"
    if not classObject.stat_time:
        info='上传失败：请检查数据表中字段是否符合模板要求（数据统计时间必须存在）'
        return info
    try:
        session = get_session()
        session.query(tmall_flagship_store_overview_day_input).filter(tmall_flagship_store_overview_day_input.stat_time == classObject.stat_time).delete()
        session.add(classObject)
        session.commit()
        session.close()
    except Exception as e:
        info = str(e)
    return info